<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>房屋信息操作</title>
    <script src="../../res/js/jquery-3.4.1.min.js"></script>
    <script src="../../res/layui/layui.js" charset="utf-8"></script>
    <script src="../../res/js/Tools.js"></script>
    <link rel="stylesheet" href="../../res/layui/css/layui.css" media="all">
    <link href="../../res/echarts/eleTree.css" rel="stylesheet" />
    <script src="../../res/echarts/eleTree.js"></script>
    <script src="../../res/js/login_common.js" charset="utf-8"></script>
    <style type="text/css">
        body {
            padding: 10px;
        }
    </style>

</head>
<body>
<form class="layui-form" action="">
    <input type="hidden" id="userId" name="userId">
    <div class="layui-form-item">

        <div class="layui-inline">
            <label class="layui-form-label">用户名：</label>
            <div class="layui-input-inline">
                <input type="text" name="userName" id="userName" lay-verify="required" placeholder="请输入用户名（必填）"
                       autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">账户名：</label>
            <div class="layui-input-inline">
                <input type="text" name="userAccount" id="userAccount" lay-verify="required" placeholder="请输入账号（必填）"
                       autocomplete="off"
                       class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">

        <div class="layui-inline">
            <label class="layui-form-label">手机：</label>
            <div class="layui-input-inline">
                <input type="text" name="userPhone" id="userPhone" lay-verify="required|phone" placeholder="请输入手机（必填）"
                       autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">身份证：</label>
            <div class="layui-input-inline">
                <input type="text" name="userIdentity" id="userIdentity" placeholder="请输入身份证"
                       autocomplete="off"
                       class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">密码：</label>
            <div class="layui-input-inline">
                <input type="password" name="userPassword" id="userPassword" lay-verify="required" placeholder="请输入密码（必填）"
                       autocomplete="off"
                       class="layui-input">
            </div>
        </div>

        <div class="layui-inline" id="isUserType">
            <label class="layui-form-label">职位：</label>
            <div class="layui-input-inline">
                <!--<input type="password" name="userType" id="userType" lay-verify="required" placeholder="请输入"
                       autocomplete="off"
                       class="layui-input">-->
                <select name="userType" id="userType" lay-filter="level" lay-verify="required">
                    <option value="">请选择职位</option>
                    <option value="1" selected="">操作员</option>
                    <option value="2">员工</option>
                </select>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1" id="sub">立即提交</button>
        </div>
    </div>
</form>
<script type="text/javascript">

</script>
<script>
    var clients

    layui.use(['form', 'layedit', 'laydate','layer'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;

        $("#demo1-getValue").on("click",function () {
            var selectArr = clients.getValue();
            console.info(selectArr);
        })

        //监听提交
        form.on('submit(demo1)', function (data) {
            var url = "../../userAction/addOrUpdate";

            if(window.loginObj.manager.userType==1){
                data.field.userType=2;
            }
            $.post(url, data.field, function (obj) {
                if (obj.num == 1) {
                    window.parent.location.reload();//刷新父页面
                    /*var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                    parent.layer.close(index);*/
                }
            }, "json")
            return false;
        });


        //表单取值
        layui.$('#LAY-component-form-getval').on('click', function () {
            var data = form.val('example');
            alert(JSON.stringify(data));
        });

        // 修改赋值
        var userId = getQueryString("userId");
        if (userId) {
            $("#userId").val(userId);
            var url = "../../userAction/findById";
            var data = {"id": userId};
            $.post(url, data, function (obj) {
                $("#userName").val(obj.userName);             // 员工名称
                $("#userAccount").val(obj.userAccount);       // 员工账号
                $("#userPhone").val(obj.userPhone);            // 手机
                $("#userIdentity").val(obj.userIdentity);       // 身份证
                $("#userPassword").val(obj.userPassword);           // 密码
                form.render();
            }, "json")
        }

        // 查看
        /*var show = getQueryString("show");
        if(show){
            $("#sub").hide();
        }*/

        //console.info(window.loginObj.manager.userType+"用户类型")
        if(window.loginObj.manager.userType==1){
            $("#isUserType").hide();
        }

        form.render();
    });
</script>
<!--
<script type="text/javascript">
    /**
     * 修改日历格式
     * @param dates
     * @returns {string}
     */
    function setDate(dates) {
        var date = new Date(dates);
        var month = date.getMonth() + 1;
        var day = date.getDate();
        var sdate = date.getFullYear() + "-"
        if (month < 10) {
            sdate += "0" + month + "-";
        } else {
            sdate += month + "-";
        }
        if (day < 10) {
            sdate += "0" + day;
        } else {
            sdate += day;
        }
        return sdate;
    }
</script>-->
</body>
</html>